package com.abcd

import android.app.Activity
import com.abcd.download.DownloadReactPackage
import com.abcd.interceptor.CustomMainReactPackage
import com.abcd.toast.ToastExampleReactPackage
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import org.pgsqlite.SQLitePluginPackage
import java.util.*

/**
 * Created by mazaiting on 2018/7/4.
 */
class LocalReactActivityDelegate(activity: Activity?, mainComponentName: String?) : ReactActivityDelegate(activity, mainComponentName) {
  private val mReactNativeHost = object : ReactNativeHost(MainApplication.INSTANCE) {
    override fun getUseDeveloperSupport(): Boolean {
      return BuildConfig.DEBUG
    }
    
    override fun getPackages(): List<ReactPackage> {
      return Arrays.asList(
              CustomMainReactPackage(),
//              CustomMainReactPackage_Java(),
              DownloadReactPackage(),
              ToastExampleReactPackage(),
              SQLitePluginPackage()
      )
    }
    
    override fun getJSMainModuleName(): String {
      return "index"
    }
    
//    override fun getJSBundleFile(): String? {
//      return "${Environment.getExternalStorageDirectory()}/index.android.bundle"
//    }
  }
  
  override fun getReactNativeHost(): ReactNativeHost {
    return mReactNativeHost
  }
}